package com.xiaoshuidi.cloud.module.iot.enums;

import org.springframework.util.StringUtils;

/**
 * 水滴密码记录的枚举
 * @author wael
 * @since 2022.11.9
 */
public enum PassWordStatusEnum {
    // 0冻结1生效2过期3未生效4执行中5添加失败
    FROZEN("0","冻结"),
    EFFECTIVE("1","生效"),
    EXPIRE("2","过期"),
    UN_EFFECTIVE("3","未生效"),
    WAITING("4","执行中"),
    FAIL("5","添加失败")
    ;
    private String code;
    private String desc;

    PassWordStatusEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static PassWordStatusEnum getInstanceByCode(String code){
        if(StringUtils.isEmpty(code)){
            return null;
        }
        for (PassWordStatusEnum pwdStatusEnum: values()) {
            if(pwdStatusEnum.getCode().equals(code)){
                return pwdStatusEnum;
            }
        }
        return null;
    }
}
